package com.demo.mvp.model;

import java.util.List;

import com.demo.db.DhDB;
import com.demo.ioc.IocContainer;
import com.demo.ioc.annotation.Inject;
import com.demo.mvp.bean.UserBean;

public class UserModel implements IUserModel
{
	
	@Inject
	DhDB db;
	
	public UserModel(){
		db = IocContainer.getShare().get(DhDB.class);
	}

	@Override
	public boolean login(String name, String password)
	{
		UserBean user =db.queryFrist(UserBean.class, ":name = ? or :password = ?", name,password);
		if(user!=null)
			return false;
		else
			return true;
	}

	@Override
	public boolean add(UserBean userBean)
	{
		// TODO Auto-generated method stub
		db.save(userBean);
		return false;
	}

	@Override
	public List<UserBean> query(int id)
	{
		// TODO Auto-generated method stub
		return db.queryList(UserBean.class, ":id = ?", id);
	}

	@Override
	public boolean delete(UserBean userBean)
	{
		db.delete(userBean);
		return false;
	}

}
